﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using JigLibX.Math;
using JigLibX.Physics;
using JigLibX.Geometry;
using JigLibX.Collision;

using ProceduralGolf.physics;

namespace ProceduralGolf
{
    class GolfBall : SphereObject
    {
        public CollisionSkin Skin { get { return skin; } }

        public GolfBall(Game game, Vector3 position)
            : base(game, position, 0.5f)
        { }
            

        public void addCallBack(CollisionCallbackFn fn)
        {
            skin.callbackFn += fn;
        }

        public void ApplyForce(float power, Vector3 direction)
        {
            Body.SetActive();
            direction.Normalize();
            Body.Velocity = direction * power;
        }

        public void ApplyForce(Vector3 direction)
        {
            Body.SetActive();
            Body.Velocity = direction;
        }

        public void SetPosition(Vector3 position)
        {
            Body.ClearForces();
            Body.Position = position;
        }

        public bool IsActive()
        {
            return Body.IsActive;
        }
    }
}
